<template>
  <div>
    <a-card :bordered="false">
      <a-tabs @tabClick="tabClick" :defaultActiveKey="current" v-model="current" style="margin-top: -25px" :animated='false'>
        <a-tab-pane tab="利润明细表" key="form1">
          <tab1 ref="form1"  v-if="current=='form1'"></tab1>
        </a-tab-pane>
        <a-tab-pane tab="利润汇总表" key="form2">
          <tab2 ref="form2"  v-if="current=='form2'"></tab2>
        </a-tab-pane>
        <a-tab-pane tab="产品利润汇总" key="form3">
          <tab3 ref="form3" v-if="current=='form3'"></tab3>
        </a-tab-pane>
        <a-tab-pane tab="招商利润汇总" key="form4">
          <tab4 ref="form3" v-if="current=='form4'"></tab4>
        </a-tab-pane>
      </a-tabs>
    </a-card>
  </div>
</template>
<script>

  import api from '../../js/api'
  import Tab1 from './tab1'
  import Tab2 from './tab2'
  import Tab3 from './tab3'
  import Tab4 from './tab4'

  export default {
    name: 'ProfitTabs',
    components: { Tab1, Tab2, Tab3,Tab4 },
    data() {
      let me = this
      return {
        api: Object.assign(api, this.api),
        //列表初始化查询参数
        queryParam: {},
        searchParams: {
          orderNo:''
        },
        current: 'form1',
        forms: [
          'form1',
          'form2',
          'form3',
          'form4',
          'form5'
        ]
      }
    },
    created() {
    },
    methods: {
      tabClick(name) {
        this.current = name
        this.$nextTick(() => {
          this.searchHandler(this.searchParams)
        })
      },
      deptChange(value){
        this.$refs.search.queryParam.deptId=value;
        this.searchHandler(this.$refs.search.queryParam);
      },
      searchHandler(searchParams) {
        this.searchParams = searchParams
        if( this.current=='form2')
        {
          this.$refs[this.current].openMultiple(searchParams)
        }
        this.$refs[this.current].searchHandler(searchParams)
      }
    }
  }
</script>
